<!DOCTYPE html>
<meta charset="utf-8">
<title>
  <%= app_name %>
  <% if @model %>
  - <%= @model.display_name %>
  <% end %>
  <% if @resource %>
  - <%= @resource.display_name %>
  <% end %>
</title>
<link href="<%= stylesheet_path "application" %>" rel="stylesheet">
<script src="<%= javascript_path "application" %>"></script>

<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="/"><%= app_name %></a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="/user/<%= current_user.id %>/edit"><%= t(:welcome) % h(current_user.name) %></a></li>
        <li><a href="/_logout"><%= t :sign_out %></a></li>
      </ul>
      <% if @model %>
      <form class="navbar-form navbar-right" method="get" action="<%= path_for(search: "") %>">
        <input type="search" class="form-control <%= 'not-empty' if params[:search].present? %>" id="_search" name="search" placeholder="Search <%= @model.search_fields.map { |e| t @model.fields[e] }.join(", ") if @model %>" value="<%= h params[:search] %>" style2="width: 300px;">
      </form>
      <% end %>
    </div>
  </div>
</nav>

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-3 col-md-2 sidebar">
      <ul class="nav nav-sidebar">
        <% Mongoid.models.each do |klass| %>
        <% next if klass.for(current_user).nil? %>
        <li class="<%= 'active' if @model == klass %>"><a href="/<%= klass.name.underscore %>"><%= klass.display_name %></a></li>
        <% end %>
      </ul>
    </div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <%= yield %>
    </div>
  </div>
</div>
